package org.reliablesource.prism.gef.editor;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IElementFactory;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.PlatformUI;
import org.reliablesource.prism.core.IPrismScreen;

public class PrismScreenEditorInputFactory implements IElementFactory {

	public static final String ID = "org.reliablesource.prism.gef.editor.PrismScreenEditorInputFactory";
	
	/**
	 * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
	 */
	public IAdaptable createElement(final IMemento memento) {
		StructuredSelection selection = (StructuredSelection) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
		return new PrismScreenEditorInput((IPrismScreen) selection.getFirstElement());
	}
}
